package com.shundr.shipper.common.util;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;

import com.shundr.shipper.common.view.DialogDisplay.OnDisplayListener;

public class DialogUtil {

	/**
	 * 
	 * noticeAlertDialog(这里用一句话描述这个方法的作用)
	 * (这里描述这个方法适用条件 – 可选)
	 * @param context
	 * @param title
	 * @param content
	 * @param displayListener
	 * void
	 * @exception
	 * @since  1.0.0
	 */
	public static void noticeAlertDialog(Context context, String title,
			String content, final OnDisplayListener displayListener) {
		new AlertDialog.Builder(context).setTitle(title)
				.setMessage(content)
				.setOnCancelListener(new OnCancelListener() {
					
					@Override
					public void onCancel(DialogInterface dialog) {
						displayListener.cancel();
					}
				})
				.setPositiveButton("确认", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						displayListener.confirm();

					}
				})
				.setNegativeButton("取消", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						displayListener.cancel();
					}
				}).show();
	}
	
	/**
	 * 带button提示信息的dialog
	 * noticeAuthDialog(这里用一句话描述这个方法的作用)
	 * (这里描述这个方法适用条件 – 可选)
	 * @param context
	 * @param title
	 * @param content
	 * @param confirmText
	 * @param cancelText
	 * @param displayListener
	 * void
	 * @exception
	 * @since  1.0.0
	 */
	public static void noticeAuthDialog(Context context, String title,
			String content, String confirmText, String cancelText, final OnDisplayListener displayListener) {
		new AlertDialog.Builder(context).setTitle(title)
				.setMessage(content)
				.setOnCancelListener(new OnCancelListener() {
					
					@Override
					public void onCancel(DialogInterface dialog) {
						displayListener.cancel();
					}
				})
				.setPositiveButton(confirmText, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						displayListener.confirm();

					}
				})
				.setNegativeButton(cancelText, new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						displayListener.cancel();
					}
				}).show();
	}

}
